import 'package:extended_tabs/extended_tabs.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sports_new/controller/pick/ai_logic.dart';
import 'package:sports_new/view/pick/ai/ai_page.dart';
import 'package:sports_new/view/pick/subs/subs_page.dart';
import '../../resources/colours.dart';
import '../../resources/styles.dart';
import '../../utils/utils.dart';
import '../../widgets/base/qkd_indicator.dart';

class PickLogic extends GetxController with GetSingleTickerProviderStateMixin{
  late final TabController controller;
  List<Widget> pageList = const [AiPage(), SubsPage()];
  int _index = 0;

  int get index => _index;

  set index(int value) {
    _index = value;
    update();
  }

  @override
  void onInit() {
    controller = TabController(length: 2, vsync: this,initialIndex: index);
    controller.addListener(() {
      index = controller.index;
    });
    super.onInit();
  }

  void toIndex(int i){
    controller.animateTo(i);
  }

  doRefresh(){
    Get.find<AiLogic>().doRefresh();
  }
}

class PickPage extends StatefulWidget {
  const PickPage({Key? key}) : super(key: key);

  @override
  State<PickPage> createState() => _PickPageState();
}

class _PickPageState extends State<PickPage>{
  final PickLogic logic = Get.put(PickLogic());

  @override
  Widget build(BuildContext context) {
    return GetBuilder<PickLogic>(
      builder: (logic) => const AiPage()
    );
  }
}
